<?php
/**
* phpCan - http://idc.anavallasuiza.com/
*
* phpCan is released under the GNU Affero GPL version 3
*
* More information at license.txt
*/

defined('ANS') or die();
?>

<header>
	<hgroup>
		<h1><?php echo $table_info['title']; ?></h1>
		<h2><?php __e('%s related with %s %s #%s', $table_info['relation_direction'], $table_info['relation_table'], $table_info['relation_name'], $Vars->get('relation_id')); ?></h2>
	</hgroup>

	<nav>
		<?php
		echo $Html->a(array(
			'text' => __('Only related elements'),
			'href' => path(),
			'class' => 'button'.($Vars->get('all') ? '' : ' secondary'),
			'data-icon' => 'link'
		));
		echo $Html->a(array(
			'text' => __('All elements'),
			'href' => path().get('all', true),
			'class' => 'button'.($Vars->get('all') ? ' secondary' : ''),
			'data-icon' => 'search'
		));
		echo $Html->a(array(
			'text' => __('New'),
			'href' => path(true, true, 'new').get(array(
				'relation' => $Vars->get('relation'),
				'relation_id' => $Vars->get('relation_id'),
				'redirect' => path().get()
			)),
			'class' => 'button',
			'data-icon' => 'plus'
		));
		?>
	</nav>

	<?php $Templates->render('aux-search.php', array('action_url' => path())); ?>
</header>

<article>
	<?php if ($list['body']): ?>

	<table class="list">
		<thead><?php $Templates->render('aux-list-table-head.php', array('header' => $list['head'])); ?></thead>

		<tbody>
			<?php
			$Templates->render('aux-list-table-body.php', array(
				'rows' => $list['body'],
				'actions_template' => 'aux-relations-table-body-actions.php'
			));
			?>
		</tbody>
	</table>

	<?php $Templates->render('aux-pagination.php', array('pagination' => $pagination)); ?>

	<?php else: ?>
	<?php echo ad(__('No results have been found')); ?>
	<?php endif; ?>
</article>
